package com.znn.dagger2demo;

import android.app.Application;
import android.location.LocationManager;
import android.util.Log;

import com.google.gson.Gson;
import com.znn.dagger2demo.component.ApplicationComponent;
import com.znn.dagger2demo.component.DaggerApplicationComponent;
import com.znn.dagger2demo.module.AppApplicationModule;

import javax.inject.Inject;

/**
 * @author RANDY.ZHANG
 * @version 1.0
 * @company:
 * @date 16/8/8 16:22
 */
public class MyApplication extends Application{

    private ApplicationComponent component;

    private static MyApplication instance;

    public static MyApplication getInstance() {
        return instance;
    }

    @Inject
    LocationManager locationManager;

    @Inject
    Gson gson;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        component = DaggerApplicationComponent.builder()
                .appApplicationModule(new AppApplicationModule(this))
                .build();
        component.inject(this);
        Log.i("", "locationManager:"+Integer.toHexString(locationManager.hashCode()));
        Log.i("", "gson:"+Integer.toHexString(gson.hashCode()));
    }

    public ApplicationComponent getComponent() {
        return component;
    }
}
